package fr.enseirbmatmeca.apms.spring.model.project;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;

import org.hibernate.annotations.GenericGenerator;

import fr.enseirbmatmeca.apms.spring.model.user.User;
import javax.persistence.Temporal;

@Entity
public class ProjectCollection {
	
	/**
	 * 
	 * this class reference a collection of project
	 * It should be used by Administrators to create a group of project for a particular "lesson"
	 * 
	 * 
	 * @author coudar
	 * 
	 */

	public final static int STATUS_PAS_ENCORE_REDIGES = 0;
	public final static int STATUS_REDIGES = 1;
	public final static int STATUS_CHOIX_PROJETS = 2;
	public final static int STATUS_PROJETS_AFFECTES = 3;
	public final static int STATUS_PROJETS_RENDUS = 4;
	
	private String id;
	private List<Project> projects;
	private int status;
	private String name;
	private String description;
	private Date deadline; //deadline to next status
	private List<User> tutors; // can modify this project collection
	private String promotion; // promotion assigned to the project collection
	
	@Column
        @Temporal(javax.persistence.TemporalType.DATE)
	public Date getDeadline() {
		return deadline;
	}
	@Column
	public String getDescription() {
		return description;
	}
	
	@Id
    @GeneratedValue(generator = "system-uuid")
    @GenericGenerator(name = "system-uuid", strategy = "uuid")
    @Column(unique = true, nullable = false)
	public String getId() {
		return id;
	}
	
	@Column(nullable = false)
	public String getName() {
		return name;
	}
	
	@OneToMany(targetEntity=Project.class, fetch=FetchType.LAZY)
	public List<Project> getProjects() {
		return projects;
	}
	
	@Column(nullable = false, columnDefinition = "int default "+STATUS_PAS_ENCORE_REDIGES)
	public int getStatus() {
		return status;
	}
	
	@ManyToMany(targetEntity=User.class, fetch=FetchType.LAZY)
	public List<User> getTutors() {
		return tutors;
	}
	
	public void setDeadline(Date deadline) {
		this.deadline = deadline;
	}
	
	public void setDescription(String description) {
		this.description = description;
	}
	
	public void setId(String id) {
		this.id = id;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public void setProjects(List<Project> projects) {
		this.projects = projects;
	}
	
	public void setStatus(int status) {
		this.status = status;
	}
	
	public void setTutors(List<User> tutors) {
		this.tutors = tutors;
	}
	
	@Column
	public String getPromotion() {
		return promotion;
	}
	public void setPromotion(String promotion) {
		this.promotion = promotion;
	}
	
}
